﻿using System.ComponentModel;

namespace DatabaseGroup.SSIS.SourceAdapters.View
{
    /// <summary>
    /// For handling events linked to a property value update
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void CancelPropertyUpdateEventHandler(object sender, CancelPropertyUpdateEventArgs e);

    /// <summary>
    /// A cancellable event args that specifies the property being updated
    /// along with (optionally) the value it is changing from/to
    /// </summary>
    public class CancelPropertyUpdateEventArgs : CancelEventArgs
    {
        /// <summary>
        /// Initializes a new instance of the CancelPropertyUpdateEventArgs class
        /// using the propertyName
        /// </summary>
        /// <param name="propertyName">The name of the property the event relates to</param>
        public CancelPropertyUpdateEventArgs(string propertyName)
        {
            this.PropertyName = propertyName;
        }

        /// <summary>
        /// The name of the property the event relates to
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// The value the property is changing from
        /// </summary>
        public object OldValue { get; set; }

        /// <summary>
        /// The value the property is changing to
        /// </summary>
        public object NewValue { get; set; }
    }
}
